home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Presentations
/
Presentations ’91
/
DAL Files
/
DALtool 4⁄19 (System 6.x)
/
DalDialog.c
< prev
next >
Wrap
Text File
|
1991-04-18
|
2KB
|
118 lines
#include "DalDemo.h"
extern char gPassword[],gUsername[], gNodename[];
/*** CreateSession ***/
CreateSession()
{
DialogPtr logonDialog;
int dialogDone = FALSE;
int itemHit;
int itemType;
Rect itemRect;
Handle itemHandle, OKHandle;
demoPeek demoWind;
Boolean doCreate;
doCreate = FALSE;
logonDialog = GetNewDialog(LOGON_DIALOG,NIL,MOVE_TO_FRONT);
GetDItem(logonDialog, OK_BUTTON, &itemType, &OKHandle, &itemRect);
ShowWindow(logonDialog);
SetPort(logonDialog);
DrawOKButton(logonDialog);
while (!dialogDone)
{
GetDItem(logonDialog, LOGON_PSWD, &itemType, &itemHandle, &itemRect);
GetIText(itemHandle, &gPassword);
if (gPassword[0] != NIL)
HiliteControl(OKHandle, 0);
else
HiliteControl(OKHandle, 255);
ModalDialog(SignonFilter,&itemHit);
switch (itemHit)
{
case OK_BUTTON:
GetDItem(logonDialog, LOGON_NODE, &itemType, &itemHandle, &itemRect);
GetIText(itemHandle, &gNodename);
GetDItem(logonDialog, LOGON_NAME, &itemType, &itemHandle, &itemRect);
GetIText(itemHandle, &gUsername);
doCreate = TRUE;
case CANCEL_BUTTON:
dialogDone = TRUE;
HideWindow(logonDialog);
break;
}
}
if (doCreate)
{
CreateWindow();
demoWind = (demoPeek) FrontWindow();
DALOpenLink(demoWind,gNodename, gUsername, gPassword);
}
}
/*** DrawOKButton ***/
DrawOKButton(dp)
DialogPtr dp;
{
int itemType;
Rect itemRect;
Handle item;
GrafPtr oldPort;
GetDItem(dp, OK_BUTTON, &itemType, &item, &itemRect);
GetPort(&oldPort);
SetPort( dp);
PenSize(3,3);
InsetRect(&itemRect,-4,-4);
FrameRoundRect(&itemRect,16,16);
PenNormal();
SetPort(oldPort);
}
/*** SignonFilter ***/
pascal Boolean SignonFilter(dp, theEvent, itemHit)
DialogPtr dp;
EventRecord *theEvent;
int *itemHit;
{
Handle item;
int itemType;
Rect itemRect;
char theChar;
Str255 theStr;
int selStart,selEnd;
int flag = FALSE;
GetDItem( dp, LOGON_PSWD, &itemType, &item, &itemRect);
GetIText( item, &theStr);
if ((theEvent->what == keyDown) || (theEvent->what == autoKey))
{
theChar = (theEvent->message & charCodeMask);
if ((theChar == TE_CARRIAGE_RETURN) || (theChar == TE_ENTER_KEY))
{
if (theStr[0] != NIL)
{
*itemHit = OK_BUTTON;
GetDItem(dp, OK_BUTTON, &itemType, &item, &itemRect);
HiliteControl(item,1);
return(TRUE);
}
else
{
*itemHit = LOGON_PSWD;
return(TRUE);
}
}
}
return(FALSE);
}